import {getSearchInfo} from '@/api'
const state={
    searchInfo:{}
}
const actions={
    async getSearchInfo({commit},params={}){
        let result=await getSearchInfo(params)
        console.log(result);
        if (result.code===200) {
            commit("GETRESEARCHINFO",result.data)
        }
    }
}
const mutations={
    GETRESEARCHINFO(state,searchInfo){
        state.searchInfo=searchInfo
    }
}
//简化数据，用mapGetters
const getters={
    //行参是当前state数据
    goodsList(state){
        return state.searchInfo.goodsList||[];//空对象时无.goodList
    },
    trademarkList(state){
        return state.searchInfo.trademarkList||[];
    },
    attrsList(state){
        return state.searchInfo.attrsList||[];
    },
}

export default {
    state,actions,mutations,getters
}